def warden(k,n):
    dp=[[0 for _ in range(n+1)] for _ in range(k)]

    #先判断第一行的情况
    for i in range(n+1):
        #最多走一步，所以到达每个监狱的方法都只有一种
        dp[0][i]=1
    for i in range(1,k):
        for j in range(n+1):
            dp[i][j]=dp[i-1][j]
            if j>=k:
                count=0
                sum=0
                while count<k:
                    sum+=dp[i][j-count-1]
                    count+=1
                dp[i][j]=sum
    print(dp)
warden(2,4)
